const { defineConfig } = require('@vue/cli-service');
module.exports = defineConfig({
  // transpileDependencies: true,
  publicPath: '/tapwater',
  lintOnSave: process.env.NODE_ENV === 'development',
  // publicPath: "/zhzs", //process.env.VUE_APP_SUB_PATH ||
  // 在npm run build 或 yarn build 时 ，生成文件的目录名称（要和baseUrl的生产环境路径一致）（默认dist）
  outputDir: 'tapwater',
  assetsDir: 'static',
  productionSourceMap: false,
  devServer: {
    host: '0.0.0.0',
    // port: port,
    open: false,
    proxy: {
      [process.env.VUE_APP_BASE_API + '/getinfo']: {
        target: 'http://192.168.0.21:8081',
        // target: 'http://192.168.0.21:8081',
        changeOrigin: false,
        pathRewrite: {
          ['^' + process.env.VUE_APP_BASE_API + '/getinfo']: '',
        },
      },

      [process.env.VUE_APP_BASE_API + '/weather']: {
        target: 'http://t.weather.itboy.net',
        changeOrigin: true,
        pathRewrite: {
          ['^' + process.env.VUE_APP_BASE_API + '/weather']: '',
        },
      },
      [process.env.VUE_APP_BASE_API + "/mapTile"]: {
        target: 'http://192.168.0.17:86',//本地测试
        // target: 'http://192.168.0.20:86',
        changeOrigin: true,
        pathRewrite: {
          ['^' + process.env.VUE_APP_BASE_API + "/mapTile"]: ''
        }, onProxyRes(proxyRes, req, res) {
          const realUrl = req.url || ''; // 确保这里只包含有效的URL字符
          proxyRes.headers['A-Real-Url'] = realUrl; // 添加响应头
        },
      },
      [process.env.VUE_APP_BASE_API + "/dmgis"]: {
        // target: 'http://192.168.0.15:8808',//本地测试
        // target: 'http://192.168.0.30:8808',//本地测试
        // target: 'http://192.168.0.23:8808',
        target: 'http://localhost:8808',
        changeOrigin: true,
        pathRewrite: {
          ['^' + process.env.VUE_APP_BASE_API + "/dmgis"]: ''
        }, onProxyRes(proxyRes, req, res) {
          const realUrl = req.url || ''; // 确保这里只包含有效的URL字符
          proxyRes.headers['A-Real-Url'] = realUrl; // 添加响应头
        },
      },
      [process.env.VUE_APP_BASE_API + "/arcgis"]: {
        target: 'http://218.4.157.242:8083',
        changeOrigin: true,
        pathRewrite: {
          ['^' + process.env.VUE_APP_BASE_API + "/arcgis"]: ''
        }, onProxyRes(proxyRes, req, res) {
          const realUrl = req.url || ''; // 确保这里只包含有效的URL字符
          proxyRes.headers['A-Real-Url'] = realUrl; // 添加响应头
        },
      },
    },
    client: {
      overlay: false,
    },
    allowedHosts: 'all',
  },
 
});
